package com.zrz.service;

import com.zrz.dao.auto.BannerMapper;
import com.zrz.model.auto.Banner;
import com.zrz.model.auto.BannerExample;
import com.zrz.util.Json;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import java.util.List;

@Service
public class ImageService {
    @Autowired
    private BannerMapper bannerMapper;

    public List<Banner> imageUrl(Integer houseId, Integer type) {
        BannerExample bannerExample = new BannerExample();
        BannerExample.Criteria criteria = bannerExample.createCriteria();
        if (houseId != null) {
            criteria.andHouseIdEqualTo(houseId);
        }
        if (type != null) {
            criteria.andTypeEqualTo(type);
        }
        List<Banner> banners = bannerMapper.selectByExample(bannerExample);
        if (CollectionUtils.isEmpty(banners)) {
            return null;
        } else {
            return banners;
        }
    }
}
